var w1 = ["一日之计在于晨。", "美好的下午开始啦！", "好好休息啦！"]; //定义字符串
var date; //定义date对象
var hour, minute, second; //定义时间变量，时分秒
var year, month, day; //定义年月日
var week; //定义周几

//获取html标签
var h = document.getElementById("h");
var m = document.getElementById("m");
var ss = document.getElementById("ss");
console.log(ss);
var year_ = document.getElementById("year");
var month_ = document.getElementById("month");
var day_ = document.getElementById("date");
var week_ = document.getElementById("week");
var i1 = document.getElementById("i1");

function getTime() { //执行一次可以获取当前时间并更新在html页面上
	date = new Date();
	hour = date.getHours();
	minute = date.getMinutes();
	second = date.getSeconds();
	
	if (hour < 12) {
		i1.innerHTML = "早晨";
		i2.innerHTML = w1[0];
		$('#time-i2').html(w1[0]);
		$('#time-i1').html('早晨');
	} else if (hour >= 12 && hour <= 18) {
		i1.innerHTML = "下午";
		i2.innerHTML = w1[1];
		$('#time-i2').html(w1[1]);
		$('#time-i1').html('下午');
	} else {
		i1.innerHTML = "晚上";
		i2.innerHTML = w1[2];
		$('#time-i2').html(w1[2]);
		$('#time-i1').html('晚上');
	}
	if (hour < 10) {
		hour = "0" + hour;
	} else if (hour > 12) {
		hour = hour - 12;
	}
	if (minute < 10) {
		minute = "0" + minute;
	}
	if (second < 10) {
		second = "0" + second;
	}
	h.innerHTML = hour;
	m.innerHTML = minute;
	ss.innerHTML = second;
}
getTime();
setInterval(getTime, 900);

function getDate() { //执行后获取当前日期
	date = new Date();
	year = date.getFullYear();
	month = date.getMonth() + 1;
	console.log(month);
	day = date.getDate();
	// if(month1<10)month1="0"+month1;
	// if(day1<10)month1="0"+day1;
	week = "周" + ['日', '一', '二', '三', '四', '五', '六'][date.getDay()];
	year_.innerHTML = year;$('#time-year').html(year);
	month_.innerHTML = month;$('#time-month').html(month);
	day_.innerHTML = day;$('#time-date').html(day);
	week_.innerHTML = week;$('#time-week').html(week);
}
getDate();


